package com.yhf.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yhf.dto.ProjectOv;
import com.yhf.dto.SubitemDto;
import com.yhf.model.Subitem;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

@Mapper
public interface SubitemMapper extends BaseMapper<Subitem> {
    @Results(id = "subitemdto",value = {
            @Result(column = "suid",property = "suid"),
            @Result(column = "sname",property = "sname"),
            @Result(column = "starttime",property = "starttime"),
            @Result(column = "endtime",property = "endtime"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "status",property = "status"),
            @Result(column = "pid",property = "pid"),
            @Result(column = "pid",property = "projectOv",javaType = ProjectOv.class,one =
            @One(select = "com.yhf.mapper.PMapper.selectByPid",fetchType = FetchType.EAGER))
    })
    @Select("select * from subitem ${ew.customSqlSegment}")
    IPage<SubitemDto> selectAll(Page<SubitemDto> page, @Param(Constants.WRAPPER) QueryWrapper<SubitemDto> queryWrapper);

    @ResultMap("subitemdto")
    @Select("Select * from subitem where suid = #{suid}")
    SubitemDto selectBySuId(@Param("suid") String suid);
}
